import request from '@/utils/request'

export const GetMaps = (pid) => {
  return request({
    url: '/maps?pid=' + pid,
    method: 'get',
  })
}

export const GetMap = (adcode) => {
  return request({
    url: '/maps/getMap',
    method: 'get',
    params: {
      adcode: adcode
    },
  })
}

export const CreateMap = (data) => {
  return request({
    url: '/maps/store',
    method: 'post',
    data: data,
  })
}

export const UpdateMap = (data) => {
  return request({
    url: '/maps/update',
    method: 'post',
    data: data,
  })
}

export const GetAddress = pid => {
  return request({
    url: 'address',
    method: 'get',
    params: {
      pid: pid
    }
  })
}

export const Login = (policeId, userPassword) => {
  return request({
    url: '/login',
    method: 'post',
    data: {
      policeId,
      userPassword
    }
  })
}

export const YearsOfService = () => {
  return request({
    url: 'userpersona/yearsofservice',
    method: 'get'
  })
}

export const Age = () => {
  return request({
    url: 'userpersona/age',
    method: 'get'
  })
}

export const Location = () => {
  return request({
    url: 'userpersona/location',
    method: 'get'
  })
}

export const Progress = () => {
  return request({
    url: 'userpersona/progress',
    method: 'get'
  })
}

export const Job = () => {
  return request({
    url: 'userpersona/job',
    method: 'get'
  })
}

export const DriverTime = () => {
  return request({
    url: 'driverpersona/time',
    method: 'get'
  })
}

export const DriverVehicleType = () => {
  return request({
    url: 'driverpersona/driver-vehicle-type',
    method: 'get'
  })
}

export const DriverAge = () => {
  return request({
    url: 'driverpersona/age',
    method: 'get'
  })
}

export const DriverGender = () => {
  return request({
    url: 'driverpersona/gender',
    method: 'get'
  })
}

export const ScenePage = (pageNum,pageSize,userName,policeId) => {
  return request({
    url: '/scene/page',
    method: 'get',
    params: {
      pageNum,
      pageSize,
      userName,
      policeId
    }
  })
}
export const SceneSave = (form) => {
  var data = {};
  if (form.accidentId != undefined) data.accidentId = form.accidentId;
  if (form.arriveTime != undefined) data.arriveTime = form.arriveTime;
  if (form.weather != undefined) data.weather = form.weather;
  if (form.roadType != undefined) data.roadType = form.roadType;
  if (form.accidentLocation != undefined) data.accidentLocation = form.accidentLocation;
  if (form.accidentDescription != undefined) data.accidentDescription = form.accidentDescription;
  if (form.accidentComments != undefined) data.accidentComments = form.accidentComments;
  if (form.surveyor != undefined) data.surveyor = form.surveyor;
  if (form.draftsman != undefined) data.draftsman = form.draftsman;
  if (form.party != undefined) data.party = form.party;
  if (form.witness != undefined) data.witness = form.witness;
  if (form.mapTime != undefined) data.mapTime = form.mapTime;
  return request({
    url: '/scene/save',
    method: 'post',
    data
  })
}

export const SceneEdit = (form) => {
  var data = {};
  if (form.accidentId != undefined) data.accidentId = form.accidentId;
  if (form.arriveTime != undefined) data.arriveTime = form.arriveTime;
  if (form.weather != undefined) data.weather = form.weather;
  if (form.roadType != undefined) data.roadType = form.roadType;
  if (form.accidentLocation != undefined) data.accidentLocation = form.accidentLocation;
  if (form.accidentDescription != undefined) data.accidentDescription = form.accidentDescription;
  if (form.accidentComments != undefined) data.accidentComments = form.accidentComments;
  if (form.surveyor != undefined) data.surveyor = form.surveyor;
  if (form.draftsman != undefined) data.draftsman = form.draftsman;
  if (form.party != undefined) data.party = form.party;
  if (form.witness != undefined) data.witness = form.witness;
  if (form.mapTime != undefined) data.mapTime = form.mapTime;
  return request({
    url: '/scene',
    method: 'put',
    data
  })
}

export const PolicecaseAdd = (form) => {
  var data = {};
  if (form.userId != undefined) data.userId = form.userId;
  if (form.month != undefined) data.month = form.month;
  if (form.closedIncident != undefined) data.closedIncident = form.closedIncident;
  if (form.openIncident != undefined) data.openIncident = form.openIncident;
  if (form.incidentDistrict != undefined) data.incidentDistrict = form.incidentDistrict;
  if (form.incidentCity != undefined) data.incidentCity = form.incidentCity;
  if (form.incidentProvince != undefined) data.incidentProvince = form.incidentProvince;
  return request({
    url: 'policecase/add',
    method: 'post',
    data
  })
}

export const PolicecaseUpdate = (form) => {
  var data = {};
  if (form.userId != undefined) data.userId = form.userId;
  if (form.month != undefined) data.month = form.month;
  if (form.closedIncident != undefined) data.closedIncident = form.closedIncident;
  if (form.openIncident != undefined) data.openIncident = form.openIncident;
  if (form.incidentDistrict != undefined) data.incidentDistrict = form.incidentDistrict;
  if (form.incidentCity != undefined) data.incidentCity = form.incidentCity;
  if (form.incidentProvince != undefined) data.incidentProvince = form.incidentProvince;
  return request({
    url: 'policecase',
    method: 'put',
    data
  })
}

export const PolicecasePage = (pageNum, pageSize) => {
  return request({
    url: '/policecase/page',
    method: 'get',
    params: {
      pageNum,
      pageSize
    }
  })
}
export const PolicecaseDel = (id) => {
  return request({
    url: '/policecase/page' + id,
    method: 'delete',
  })
}

export const HomeChat = (username) => {
  return request({
    url: '/home/chat',
    method: 'get',
    params: {
      userName: username
    }
  })
}

export const UserSave = (form) => {
  var data = {};
  if (form.userName != undefined) data.userName = form.userName;
  if (form.policeId != undefined) data.policeId = form.policeId;
  if (form.userPassword != undefined) data.userPassword = form.userPassword;
  return request({
    url: 'user',
    method: 'post',
    data
  })
}

export const UserUpdate = (form) => {
  var data = {};
  if (form.userName != undefined) data.userName = form.userName;
  if (form.policeId != undefined) data.policeId = form.policeId;
  if (form.userPassword != undefined) data.userPassword = form.userPassword;
  return request({
    url: 'user',
    method: 'put',
    data
  })
}

export const UserPage = (pageNum, pageSize, userName, policeId) => {
  return request({
    url: '/user/page',
    method: 'get',
    params: {
      pageNum,
      pageSize,
      userName,
      policeId
    }
  })
}
export const UserDelete = id => {
  return request({
    url: '/user/' + id,
    method: 'delete',
  })
}
export const UserDelBatch = (ids) => {
  return request({
    url: 'user/del/batch',
    method: 'post',
    data: ids
  })
}

export const UserextSave = (form) => {
  var data = {};
  if (form.id != undefined) data.id = form.id;
  if (form.userName != undefined) data.userName = form.userName;
  if (form.policeId != undefined) data.policeId = form.policeId;
  if (form.gender != undefined) data.gender = form.gender;
  if (form.policeRank != undefined) data.policeRank = form.policeRank;
  if (form.department != undefined) data.department = form.department;
  if (form.dutyStation != undefined) data.dutyStation = form.dutyStation;
  if (form.phoneNumber != undefined) data.phoneNumber = form.phoneNumber;
  if (form.homeAddress != undefined) data.homeAddress = form.homeAddress;
  if (form.emergencyContactName != undefined) data.emergencyContactName = form.emergencyContactName;
  if (form.emergencyContactPhone != undefined) data.emergencyContactPhone = form.emergencyContactPhone;
  if (form.isActive != undefined) data.isActive = form.isActive;
  if (form.policeProvince != undefined) data.policeProvince = form.policeProvince;
  if (form.policeCity != undefined) data.policeCity = form.policeCity;
  if (form.userId != undefined) data.userId = form.userId;
  return request({
    url: 'userext/save',
    method: 'post',
    data
  })
}

export const UserextUpdate = (form) => {
  var data = {};
  if (form.id != undefined) data.id = form.id;
  if (form.userName != undefined) data.userName = form.userName;
  if (form.policeId != undefined) data.policeId = form.policeId;
  if (form.gender != undefined) data.gender = form.gender;
  if (form.policeRank != undefined) data.policeRank = form.policeRank;
  if (form.department != undefined) data.department = form.department;
  if (form.dutyStation != undefined) data.dutyStation = form.dutyStation;
  if (form.phoneNumber != undefined) data.phoneNumber = form.phoneNumber;
  if (form.homeAddress != undefined) data.homeAddress = form.homeAddress;
  if (form.emergencyContactName != undefined) data.emergencyContactName = form.emergencyContactName;
  if (form.emergencyContactPhone != undefined) data.emergencyContactPhone = form.emergencyContactPhone;
  if (form.isActive != undefined) data.isActive = form.isActive;
  if (form.policeProvince != undefined) data.policeProvince = form.policeProvince;
  if (form.policeCity != undefined) data.policeCity = form.policeCity;
  if (form.userId != undefined) data.userId = form.userId;
  return request({
    url: 'userext',
    method: 'put',
    data
  })
}

export const UserextPage = (pageNum, pageSize, userName, policeId) => {
  return request({
    url: '/userext/page',
    method: 'get',
    params: {
      pageNum: pageNum,
      pageSize,
      userName,
      policeId
    }
  })
}
export const UserextDelete = id => {
  return request({
    url: '/user/' + id,
    method: 'delete',
  })
}
export const UserextDelBatch = (ids) => {
  return request({
    url: 'user/del/batch',
    method: 'post',
    data: ids
  })
}